import Vue from 'vue';
import LoadingTemplate from "./index.vue";

const Loading = Vue.extend(LoadingTemplate);

let instance;

export default {
  open(){
    if(!instance){
      instance = new Loading({
        el: document.createElement('div')
      });
      /** 或者这样挂载也行哦 */
      // instance = new Loading().$mount();
    }
    if(instance.visible)return;
    document.body.appendChild(instance.$el);
    Vue.nextTick(() => {
      instance.visible = true;
    });
  },
  close(){
    if (instance){
      instance.visible = false;
    }
  }
}